package com.wyj.netty;

import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import io.netty.util.CharsetUtil;

import java.util.List;

/**
 * TODO:
 *
 * @author wuyijie
 * @date 2021/12/25 10:45 下午
 */
public class MessageEncoder extends MessageToMessageEncoder<String> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, String s, List<Object> list) throws Exception {
        System.out.println("【消息进行编码中···】");
        list.add(Unpooled.copiedBuffer(s, CharsetUtil.UTF_8));
    }
}
